<%--
  Created by IntelliJ IDEA.
  User: Boss
  Date: 2021/5/23
  Time: 12:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增违约</title>
    <style type="text/css">
        #hidden{
            width: 500px;
            height: 450px;
            border: #e8e8e8 solid 1px;
            padding-right: 40px;
            padding-top: 50px;
            position: absolute;
            left: 450px;
            background-color: #e8e8e8;
            /*display: none;*/
            top: 100px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <%
        String path=request.getContextPath();
        String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
</head>
<body>
<div id="hidden">
    <h3 style="text-align: center;margin-top: -35px">新增违约</h3>
    <br>
    <form class="layui-form" action="<%=basePath%>BorrowServlet?opr=findInsert" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">读者卡号</label>
            <div class="layui-input-block">
                <input type="text" name="cardId" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input wCardId">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">书籍编号</label>
            <div class="layui-input-block">
                <input type="text" name="bookId" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input wBookId">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">借书时间</label>
            <div class="layui-input-block">
                <input type="text" name="startTime" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input wStartTime">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">约定天数</label>
            <div class="layui-input-block">
                <input type="text" name="day" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input wDay">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">归还时间</label>
            <div class="layui-input-block">
                <input type="text" name="endTime" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input wEndTime">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">违约类型</label>
            <div class="layui-input-block">
                <select name="type" lay-verify="required" class="wType">
                    <option value=""></option>
                    <option value="1">失约</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">违约金额</label>
            <div class="layui-input-block">
                <input type="text" name="money" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input wMoney">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="button" name="ReBeOverdue" class="layui-btn zBeOver" lay-submit lay-filter="formDemo" value="增加">
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <input type="button" name="ReNoN" class="layui-btn"  value="关闭">
            </div>
        </div>
    </form>
</div>
<script src="js/jquery-1.12.4.js"></script>
<script src="layui/layui.js"></script>
<script type="text/javascript">
    /**
     * 新增违约表
     */
    $(".zBeOver").click(function () {
        let cardId=$(".wCardId").val();
        let bookId=$(".wBookId").val();
        let startTime=$(".wStartTime").val();
        let day=$(".wDay").val();
        let endTime=$(".wEndTime").val();
        let type=$(".wType").val();
        let money=$(".wMoney").val();
        $.ajax({
            url:"BorrowServlet?opr=findInsert",
            type:"post",
            data:{
                cardId:cardId,
                bookId:bookId,
                startTime:startTime,
                day:day,
                endTime:endTime,
                type:type,
                money:money
            },
            dataType:"json",
            success:function (data) {
                if (data){
                    layer.msg('增加成功！');
                    $("#hidden").hide();
                }else {
                    layer.msg('增加失败！');
                }
            }
        })
    })
    /**
     * 关闭按钮
     * */
    $("input[name='ReNoN']").click(function () {
        $("#hidden").hide()
    })
</script>
</body>
</html>
